package com.wifi.eshipewifi;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.wifi.BaseApplication;
import com.wifi.imp.MessageListener;

public class WebViewActivity extends AppCompatActivity implements View.OnClickListener {
    ImageButton back;
    TextView tittle;
    BaseApplication application;
    String TAG="WifiSettingActivity";
    Handler mhandler=new Handler(){//发送消息处理
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);

        }
    };
    SharedPreferences sp;
    WebView webView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_webview);
        application = (BaseApplication) getApplication();

        back = (ImageButton) findViewById(R.id.ib_back);
        tittle = (TextView) findViewById(R.id.tv_include_tittle);
        tittle.setText("长江汇");
        back.setOnClickListener(this);
        init();

    }
    boolean isGB;
    String package_unit;
    @Override
    protected void onResume() {
        super.onResume();
    }

    private void init(){
        webView = (WebView) findViewById(R.id.webView);
        //支持javascript
        webView.getSettings().setJavaScriptEnabled(true);
        // 设置可以支持缩放
        webView.getSettings().setSupportZoom(true);
        // 设置出现缩放工具
        webView.getSettings().setBuiltInZoomControls(true);
        //扩大比例的缩放
        webView.getSettings().setUseWideViewPort(true);
        //自适应屏幕
        webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        webView.getSettings().setLoadWithOverviewMode(true);

        //WebView加载web资源
        webView.loadUrl("http://www.njcjh.cn");
//        webView.loadUrl("http://www.baidu.com");
        //不使用缓存
        webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        //覆盖WebView默认使用第三方或系统默认浏览器打开网页的行为，使网页用WebView打开
        webView.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                // TODO Auto-generated method stub
                //返回值是true的时候控制去WebView打开，为false调用系统浏览器或第三方浏览器
                view.loadUrl(url);
                return true;
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.ib_back:
                this.finish();
                break;
        }
    }

}
